import apk from '../assets/icons/apk.svg';
import code from '../assets/icons/code.svg';
import dir from '../assets/icons/dir.svg';
import dmg from '../assets/icons/dmg.svg';
import doc from '../assets/icons/doc.svg';
import jpg from '../assets/icons/jpg.svg';
import md from '../assets/icons/md.svg';
import mp3 from '../assets/icons/mp3.svg';
import mp4 from '../assets/icons/mp4.svg';
import pdf from '../assets/icons/pdf.svg';
import ppt from '../assets/icons/ppt.svg';
import sketch from '../assets/icons/sketch.svg';
import txt from '../assets/icons/txt.svg';
import unknown from '../assets/icons/unknown.svg';
import xls from '../assets/icons/xls.svg';
import zip from '../assets/icons/zip.svg';

const icons = {
    apk,
    code,
    dir,
    dmg,
    doc,
    jpg,
    md,
    mp3,
    mp4,
    pdf,
    ppt,
    sketch,
    txt,
    unknown,
    xls,
    zip
}

const mapArr = [
    'dir',
    'pdf',
    'txt',
    'md',
    'apk',
    'dmg',
    'sketch',
    [['mp3', 'flac'], 'mp3'],
    [['ppt', 'pptx'], 'ppt'],
    [['doc', 'docx'], 'doc'],
    [['xls', 'xlsx'], 'xls'],
    [['jpg', 'png', 'gif', 'jpeg'], 'jpg'],
    [['mp4', 'avi', 'mov'], 'mp4'],
    [['zip', 'gz', 'tgz', 'gzip'], 'zip'],
    [['bat', 'sh'], 'code'],
];
const map = new Map();
mapArr.forEach((m) => {
if (Array.isArray(m)) {
    if (Array.isArray(m[0])) {
    m[0].forEach((m0) => {
        map.set(m0, m[1]);
    });
    } else {
    map.set(m[0], m[1]);
    }
} else {
    map.set(m, m);
}
});

const pause = (type = 'dir') => {
    const res = map.get(type.toLowerCase());
    if (!res) return icons.unknown;
    return icons[res];
};

export const getKey = (type = 'dir') => {
    const res = map.get(type.toLowerCase());
    if(!res) return 'unknown';
    return res;
}

export default pause;
  